package com.mate.cloud.chain.config;

import com.mate.cloud.chain.handler.BasicMemberDiscountHandler;
import com.mate.cloud.chain.handler.DiscountHandler;
import com.mate.cloud.chain.handler.PremiumMemberDiscountHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置责任链
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/1/27 14:07
 * @updateUser:     MI
 * @updateTime:     2025/1/27 14:07
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Configuration
public class DiscountChainConfiguration {

    @Bean
    public DiscountHandler discountChain() {
        BasicMemberDiscountHandler basicHandler = new BasicMemberDiscountHandler();
        PremiumMemberDiscountHandler premiumHandler = new PremiumMemberDiscountHandler();
        // 配置责任链
        basicHandler.setNextHandler(premiumHandler);
        return basicHandler;
    }
}
